package org.ihelpuoo.weboo.tag.ajax;

import javax.servlet.jsp.JspException;

import org.ihelpuoo.lang.StringUtils;

public class PostTag extends SettingTag
{

	private static final long	serialVersionUID	= -3498995032190175431L;

	@Override
	protected void end() throws JspException
	{
		((ViewTag)this.getParent()).setPost(this);
	}

	@Override
	public String toString()
	{
		String[] ss = StringUtils.splitIgnoreBlank(this.getBodyStringTrimed());
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < ss.length; i++)
		{
			if (i > 0)
				sb.append(',');
			sb.append(ss[i]).append(":null");
		}
		return createSegment("ajax.post").set("post",sb.toString()).toString();
	}

	@Override
	protected boolean isAvailable()
	{
		return !this.isBlankBody();
	}

}
